
<template>
	<div class="index">

		<div class="center">
			<left></left>
			<div class="right">
          <top></top>
          <div class="hei10"></div>
          <div class="where" style="background: #fff; padding: 10px 30px; font-size: 14px; color: #595959;">当前位置：分销后台><router-link to="/addPros" style="color: #409eff;">发布商品</router-link></div>
          <div class="hei10"></div>
<div class="addpro">
					<div class="step" v-if="!showmoney">
						<el-steps :active="2" align-center>
							<el-step title="定义基础产品信息" description="设置分类、定制生产规则"></el-step>
							<el-step title="定义销售页信息" description="对外宣传销售话术"></el-step>
							<el-step title="设置佣金及分销商可见" description="设置那些分销商可以销售，给多少佣金"></el-step>
							<el-step title="确认发布" description="上线销售发展用户"></el-step>
						</el-steps>
					</div>
					<div class="step" v-if="!showmoney">
						<div class="tilte">商品信息</div>
						<div class="con">

              <div class="kflexc mb20">
                <div class="kflexc zuo180">
                  <div style="margin-right: 10px;"><span class="xing">*</span></div>
                  <div>基于商品名称:</div>
                </div>
                <div class="kflexc">
                  <div><el-input v-model="shopform.title" placeholder="不超过30个字" disabled=""></el-input></div>
                  <div>
                    <el-checkbox style="margin-left: 20px;" v-if="this.shop_id == 50481 || this.shop_id == 304676" v-model="isxn">引流商品</el-checkbox>
                  </div>
                </div>
              </div>

						  <div class="kflexc mb20">
						    <div class="kflexc zuo180">
						      <div style="margin-right: 10px;"><span class="xing">*</span></div>
						      <div>商品名称:</div>
						    </div>
						    <div class="kflexc">
						      <div><el-input v-model="shopform.title" placeholder="不超过30个字" ></el-input></div>
						    </div>
						  </div>

						  <div class="kflexc mb20">
						    <div class="kflexc zuo180">

						      <div style="margin-right: 10px;"><span class="xing">*</span></div>
						      <div>商家编码(抓单标识):</div>
						    </div>
						    <div class="kflexc">
						      {{randomnum}}
						      <el-button plain type="primary" size="small" style="margin: 0 10px;"
						        @click="randomlog = true">自定义</el-button>
						      <el-tooltip class="item" effect="light"
						        content="如果要使用自动抓单系统的话，请在电商平台将该码粘贴到产品后台的“货号（商品编码）”处。每个产品都有唯一标识" placement="top">
						        <i class="el-icon-question"
						          style="color: rgb(64, 155, 250); font-size: 25px;  cursor: pointer;"></i>
						      </el-tooltip>
						    </div>
						  </div>
						</div>
						<div class="tilte">商品对外描述</div>
						<div class="con">

						  <div class="kflexc mb20">
						    <div class="kflexc zuo180">
						      <div>商品注意点:</div>
						    </div>
						    <div>
						      <el-input v-model="shopform.points" placeholder="输入商品注意点"></el-input>
						    </div>
						  </div>
						  <div class="kflexc mb20">
						    <div class="kflexc zuo180">
						      <div>商品卖点:</div>
						    </div>
						    <div class="kflexc">
						      <div><el-input v-model="shopform.selling_point" placeholder="输入卖点，使用逗号隔开"></el-input></div>
						      <div>
						        <el-tooltip class="item" effect="light" content="不超过3组词，例：资费低，流量大，免月租等，不宜过长" placement="top">
						          <i class="el-icon-question ico"></i>
						        </el-tooltip>
						      </div>
						    </div>
						  </div>




						  <div class="kflexc mb20">
						    <div class="kflexc zuo180">
						      <div>结算要求:</div>
						    </div>
						    <div>
						      <el-input v-model="shopform.commission_rule" placeholder="对外展示"></el-input>
						    </div>
						  </div>
              <div class="kflexc mb20">
                <div class="kflexc zuo180">
                  <div>销售页上传照片:</div>
                </div>
                <div>
                  <el-radio-group v-model="shopform.is_need_photo">
                  	<el-radio label="0">无需上传</el-radio>
                  	<el-radio label="1">需要上传</el-radio>
                  </el-radio-group>
                  <el-tooltip class="item" effect="light" content="仅设置是否需要在销售页下单时上传照片，选择无需上传可在批量上传照片处另行导入。" placement="top">
                  	<i class="el-icon-question"
                  	  style="color: rgb(64, 155, 250); font-size: 25px;  margin-left: 20px; cursor: pointer;"></i>
                  </el-tooltip>
                </div>
              </div>
              <div class="kflexc mb20">
                <div class="kflexc zuo180">
                  <div>销售页上传照片:</div>
                </div>
                <div>
                  <el-radio-group v-model="shopform.is_need_photo">
                  	<el-radio label="0">无需上传</el-radio>
                  	<el-radio label="1">需要上传</el-radio>
                  </el-radio-group>
                  <el-tooltip class="item" effect="light" content="仅设置是否需要在销售页下单时上传照片，选择无需上传可在批量上传照片处另行导入。" placement="top">
                  	<i class="el-icon-question"
                  	  style="color: rgb(64, 155, 250); font-size: 25px;  margin-left: 20px; cursor: pointer;"></i>
                  </el-tooltip>
                </div>
              </div>
						  <div class="kflexc mb20">
						    <div class="kflexc zuo180">
						      <div>产品主图:</div>
						    </div>
						    <div>

                  <chuantu v-if="chuantushow" ref="chuantu" :imgs="shopform.image1" @getimg="getimg"></chuantu>
						    </div>
						  </div>
						  <div class="kflexc mb20">
						    <div class="kflexc zuo180">
						      <div>商品分享图:</div>
						    </div>
						    <div class="kflexc">
						      <div>
						        <chuantu v-if="chuantushow" ref="chuantu" :imgs="shopform.share_img" @getimg="getimg2"></chuantu>
						      </div>
						      <div>
						        <el-tooltip class="item" effect="light" content="该图用于微小店分享商品处向用户说明产品优点。" placement="top">
						          <i class="el-icon-question"
						            style="color: rgb(64, 155, 250); font-size: 25px;  margin-left: 20px; cursor: pointer;"></i>
						        </el-tooltip>
						      </div>
						    </div>
						  </div>
						  <div class="kflexc mb20">
						    <div class="kflexc zuo180">
						      <div style="margin-right: 10px;"><span class="xing">*</span></div>
						      <div>商品详情:</div>
						    </div>
						    <div>
						      <div id="editor" style="width: 1200px;"></div>
						    </div>
						  </div>
						  <div class="kflexc mb20">
						    <div class="kflexc zuo180">
						      <div>其他备注:</div>
						    </div>
						    <div>
						      <div id="editorE" style="width: 1200px;"></div>
						    </div>
						  </div>
						  <div class="kflexc mb20">
						    <div class="kflexc zuo180">
						      <div>强制同步:</div>
						    </div>
						    <div>
						      <el-checkbox v-model="force_update" @change="changeforce_update">强制同步分销商此商品详情页
						      </el-checkbox>
						    </div>
						  </div>


						</div>
						<div class="tilte">套餐详细信息</div>
						<div class="con">

              <div class="kflexc">
                <div class="kflexc mb20">
                  <div class="kflexc zuo180">
                    <div style="margin-right: 10px;"><span class="ai">AI</span></div>
                    <div>商品名称:</div>
                  </div>
                  <div>
                    <el-input v-model="shopform.goods_name" placeholder="商品名称"></el-input>
                  </div>
                </div>
                <div class="kflexc mb20">
                  <div class="kflexc zuo180">
                    <div style="margin-right: 10px;"><span class="ai">AI</span></div>
                    <div>运营商:</div>
                  </div>
                  <div>
                    <el-input v-model="shopform.operator" placeholder="运营商"></el-input>
                  </div>
                </div>
                <div class="kflexc mb20">
                  <div class="kflexc zuo180">
                    <div style="margin-right: 10px;"><span class="ai">AI</span></div>
                    <div>归属地:</div>
                  </div>
                  <div>
                    <el-input v-model="shopform.guishudi" placeholder="归属地"></el-input>
                    <!-- <dizhi @xuanzhongde="xuanzhongde" :guishudi_code="shopform.guishudi_code"></dizhi> -->
                  </div>
                </div>


              </div>


						  <div class="kflexc">
						    <div class="kflexc mb20">
						      <div class="kflexc zuo180">
						        <div style="margin-right: 10px;"><span class="ai">AI</span></div>

						        <div>优惠期月租:</div>
						      </div>
						      <div>
						        <el-input v-model="shopform.discount_rent" placeholder="优惠期月租"></el-input>
						      </div>
						    </div>
						    <div class="kflexc mb20">
						      <div class="kflexc zuo180">
						        <div style="margin-right: 10px;"><span class="ai">AI</span></div>

						        <div>优惠后月租:</div>
						      </div>
						      <div>
						        <el-input v-model="shopform.yuezu" placeholder="优惠后月租"></el-input>
						      </div>
						    </div>
						  </div>

						  <div class="kflexc">
						    <div class="kflexc mb20">
						      <div class="kflexc zuo180">
						        <div style="margin-right: 10px;"><span class="ai">AI</span></div>

						        <div>首充赠送金额:</div>
						      </div>
						      <div>
						        <el-input v-model="shopform.recharge_present" placeholder="首充赠送金额"></el-input>
						      </div>
						    </div>
						    <div class="kflexc mb20">
						      <div class="kflexc zuo180">
						        <div style="margin-right: 10px;"><span class="ai">AI</span></div>

						        <div>激活首月赠送金额:</div>
						      </div>
						      <div>
						        <el-input v-model="shopform.active_present" placeholder="激活首月赠送金额"></el-input>
						      </div>
						    </div>
						  </div>

						  <div class="kflexc">
						    <div class="kflexc mb20">
						      <div class="kflexc zuo180">
						        <div style="margin-right: 10px;"><span class="ai">AI</span></div>

						        <div>语音通话:</div>
						      </div>
						      <div>
						        <el-input v-model="shopform.yuyin" placeholder="语音通话"></el-input>
						      </div>
						    </div>
						    <div class="kflexc mb20">
						      <div class="kflexc zuo180">
						        <div style="margin-right: 10px;"><span class="ai">AI</span></div>

						        <div>协议期:</div>
						      </div>
						      <div>
                    <el-select v-model="shopform.agreed_period" placeholder="输入月" style=" margin-right: 10px;">
                      <el-option :value="item" v-for="item in 36" :key="item" :label="item + '个月'"></el-option>
                    </el-select>
						      </div>
						    </div>
						  </div>

						  <div class="kflexc mb20">
						    <div class="kflexc zuo180">
						      <div style="margin-right: 10px;"><span class="ai">AI</span></div>

						      <div>通用流量:</div>
						    </div>
						    <div>
						      <el-input v-model="shopform.liuliang" placeholder="通用流量"></el-input>
						    </div>
						  </div>
						  <div class="kflexc mb20">
						    <div class="kflexc zuo180">
						      <div style="margin-right: 10px;"><span class="ai">AI</span></div>

						      <div>定向流量:</div>
						    </div>
						    <div>
						      <el-input v-model="shopform.dx_liuliang" placeholder="定向流量"></el-input>
						    </div>
						  </div>

						  <div class="kflexc mb20">
						    <div class="kflexc zuo180">
						      <div style="margin-right: 10px;"><span class="ai">AI</span></div>
						      <div>首充方式:</div>
						    </div>
						    <div>
						      <el-input v-model="shopform.recharge_type" placeholder="首充方式"></el-input>
						    </div>
						  </div>
						  <div class="kflexc mb20">
						    <div class="kflexc zuo180">
						      <div style="margin-right: 10px;"><span class="ai">AI</span></div>
						      <div>激活方式:</div>
						    </div>
						    <div>
						      <el-input v-model="shopform.active_type" placeholder="激活方式"></el-input>
						    </div>
						  </div>
						  <div class="kflexc mb20">
						    <div class="kflexc zuo180">
						      <div style="margin-right: 10px;"><span class="ai">AI</span></div>
						      <div>套餐优惠期:</div>
						    </div>
						    <div class="kflexc">
						      <el-select v-model="shopform.yuezu_time" placeholder="输入月"
						        style=" margin-right: 10px;">
						        <el-option :value="item" v-for="item in 36" :key="item" :label="item + '个月'"></el-option>
						      </el-select>
						      <div class="zuo180" style="margin-right: 10px;">优惠期起始时间：</div>
						      <div style="margin-right: 10px; color: rgb(147, 147, 147);">自激活起</div>
						      <el-select v-model="shopform.yuezu_type" placeholder="输入月"
						        style="margin-right: 10px;">
						        <el-option :value="1" label="当月"></el-option>
						        <el-option :value="2" label="次月"></el-option>
						        <el-option :value="3" label="第三月"></el-option>
						      </el-select>
						      <div style="margin-right: 10px; color: rgb(147, 147, 147);">开始</div>
						    </div>
						  </div>
						  <div class="kflexc mb20">
						    <div class="kflexc zuo180">
						      <div style="margin-right: 10px;"><span class="ai">AI</span></div>
						      <div>套餐详细信息:</div>
						    </div>
						    <div>
						      <div id="editorE2" style="width: 1200px;">
						      </div>
						    </div>
						  </div>
						</div>
						<div class="tilte">商品返费收益</div>
						<div class="con">
						  <div class="kflexc mb20">
						    <div class="kflexc zuo180">


                  <div style="margin-right: 10px;"><span class="xing">*</span></div>
						      <div>预估收益:</div>
						    </div>
						    <div>
						      <el-input v-model="shopform.expect_income" placeholder="预估收益"></el-input>
						    </div>
						  </div>
						  <div class="kflexc mb20">
						    <div class="kflexc zuo180">


						      <div>佣金结算周期:</div>
						    </div>
						    <div class="kflexc">
						      <el-select v-model="shopform.yongjin_time" placeholder="输入月"
						        style="margin-right: 10px;">
						        <el-option :value="item" v-for="item in 36" :key="item" :label="item + '个月'"></el-option>
						      </el-select>
						      <div class="zuo180" style="margin-right: 10px;">结算起始时间：</div>
						      <div style="margin-right: 10px; color: rgb(147, 147, 147);">自激活起</div>
						      <el-select v-model="shopform.yongjin_type" placeholder="输入月"
						        style="margin-right: 10px;">
						        <el-option :value="1" label="当月"></el-option>
						        <el-option :value="2" label="次月"></el-option>
						        <el-option :value="3" label="第三月"></el-option>
						      </el-select>
						      <div style="margin-right: 10px; color: rgb(147, 147, 147);">开始</div>
						    </div>
						  </div>
						  <div class="kflex mb20">
						    <div class="kflex zuo180" style=" padding-top: 10px;">


						      <div>返利设置:</div>
						    </div>
						    <div>
						      <div class="kflexc" style="margin-bottom: 20px;">
						        <div><el-radio v-model="shopform.fanli_money_type" :label="0">每月相同反费额度</el-radio></div>
						        <div class="kflexc zhouqi" style="margin-left: 20px;">
						          <div style="color: rgb(147, 147, 147); margin-right: 10px;">返费周期:</div>
						          <div>
						            <el-select v-model="shopform.fanli_time" placeholder="输入月">
						              <el-option :value="item" v-for="item in 36" :key="item" :label="item + '个月'"></el-option>
						            </el-select>
						          </div>
						          <div style="margin-right: 10px; color: rgb(51, 51, 51); margin-left: 20px;">返利起始时间：</div>
						          <div style="margin-right: 10px; color: rgb(147, 147, 147);">自激活起</div>
						          <el-select v-model="shopform.fanli_type" placeholder="输入月" style=" margin-right: 10px;">
						            <el-option :value="1" label="当月"></el-option>
						            <el-option :value="2" label="次月"></el-option>
						            <el-option :value="3" label="第三月"></el-option>
						          </el-select>
						          <div style="margin-right: 10px; color: rgb(147, 147, 147);">开始</div>
						          <div style="margin-right: 10px; color: rgb(147, 147, 147);">每月返费金额</div>
						          <div style="margin-right: 10px; color: rgb(147, 147, 147);"><el-input
						              v-model="shopform.fanli_money" placeholder="请输入金额"></el-input></div>

						        </div>
						      </div>
						      <div class="kflexc" style=" margin-bottom: 20px;">
						        <div><el-radio v-model="shopform.fanli_money_type" :label="1">每月不同返费额度</el-radio></div>
						        <div style="margin-left: 20px;">
						          <div class="kflexc" v-for="(item,index) in fanli_money_array" :key="index"
						            style="margin-bottom: 10px;">
						            <div v-if="index == 0" class="zuo180">激活当月</div>
						            <div v-if="index == 1" class="zuo180">激活次月</div>
						            <div v-if="index != 0 && index != 1"  class="zuo180">第{{index+1}}个月</div>
						            <div style="margin-left: 10px;"><el-input v-model="fanli_money_array[index]" type="number"
						                placeholder="请输入金额"></el-input></div>
						          </div>
						          <el-button type="text" @click="changefanli_money_array()" style="margin-left: 180px;">+ 添加月份</el-button>
						        </div>
						      </div>
						    </div>
						  </div>
						  <div class="kflexc mb20">
						    <div class="kflexc zuo180">

						      <div>返费方式:</div>
						    </div>
						    <div>
						      <el-select v-model="shopform.is_rebate" placeholder="输入返费方式" style="margin-right: 10px;">
						        <el-option :value="3" label="领取返费"></el-option>
						        <el-option :value="2" label="自动返费"></el-option>
						        <el-option :value="0" label="不使用返利系统"></el-option>
						      </el-select>
						    </div>
						  </div>
						  <div class="kflexc mb20">
						    <div class="kflexc zuo180">

						      <div>佣金备忘:</div>
						    </div>
						    <div>
						      <el-input v-model="shopform.commission_notes" placeholder="佣金备忘"></el-input>
						    </div>
						  </div>
						</div>


					</div>
					<div class="step" v-if="!showmoney" style="text-align: center;">
						<el-button type="danger" @click="jiancha(0)">仅保存</el-button>
						<el-button type="danger" @click="jiancha(1)">设置佣金且上架</el-button>
						<!-- 						<el-button type="danger" @click="shopsave">下一步</el-button> -->
					</div>
					<div class="step" v-if="showmoney">
						<div class="tilte">定义佣金及分销商可见</div>
						<div class="con">
							<el-form ref="form" :rules="rules" @submit.native.prevent :model="moneyform" label-width="150px">
								<el-form-item label="分销商可见设置:" prop="visible">

									<el-radio-group v-model="moneyform.visible" @change="cardid">
										<el-radio label="1">仅自己可见</el-radio>
										<el-radio label="2">全部分销商可见</el-radio>
										<el-radio label="3">选择的分销商可见</el-radio>
										<el-radio label="4">选择的分销商不可见</el-radio>
									</el-radio-group>

								</el-form-item>
								<el-form-item label="选择分销商:" v-if="kejian" @change="chakan">
									<el-select v-model="moneyform.child_shop_ids" multiple collapse-tags placeholder="请选择分销商:">
										<el-option v-for="item in moneyform.dislist" :key="item.child_shop_id" :label="item.name" :value="item.child_shop_id"></el-option>
									</el-select>
								</el-form-item>

								<el-form-item label="佣金规则设置:">
									<div v-for="item in bianjiyongjinlist" :key="item.id">
										<div v-if="item.type == 1" class="bor3">{{item.name}}：
											<span style="color: #409EFF; margin-right: 30px;">
												<span v-if="item.rules != ''">{{item.rules}}</span>
												<span v-if="item.active_commission > 0">已激活，佣金{{item.active_commission}}元。</span>
												<span v-if="item.first_recharge_one > 0">首充大于{{item.first_recharge_one}}元，佣金{{item.first_recharge_one_commission}}元。</span>
												<span v-if="item.first_recharge_two > 0">首充大于{{item.first_recharge_two}}元，佣金{{item.first_recharge_two_commission}}元。</span>
												<span v-if="item.recharge_amount_one > 0">累计充值大于{{item.recharge_amount_one}}元，佣金{{item.recharge_amount_one_commission}}元。</span>
												<span v-if="item.recharge_amount_two > 0">累计充值大于{{item.recharge_amount_two}}元，佣金{{item.recharge_amount_two_commission}}元。</span>
											</span>
											<el-button type="primary" size="mini" @click="bianjiyongjinchange(item)">编辑</el-button>
										</div>
									</div>
									<div v-for="item in bianjiyongjinlist" :key="item.id + 'x'">
										<div v-if="item.type == 3" class="bor4">{{item.name}}：
											<span style="color: #409EFF; margin-right: 30px;">
												<span v-if="item.rules != ''">{{item.rules}}</span>
												<span v-if="item.active_commission > 0">已激活，佣金{{item.active_commission}}元。</span>
												<span v-if="item.first_recharge_one > 0">首充大于{{item.first_recharge_one}}元，佣金{{item.first_recharge_one_commission}}元。</span>
												<span v-if="item.first_recharge_two > 0">首充大于{{item.first_recharge_two}}元，佣金{{item.first_recharge_two_commission}}元。</span>
												<span v-if="item.recharge_amount_one > 0">累计充值大于{{item.recharge_amount_one}}元，佣金{{item.recharge_amount_one_commission}}元。</span>
												<span v-if="item.recharge_amount_two > 0">累计充值大于{{item.recharge_amount_two}}元，佣金{{item.recharge_amount_two_commission}}元。</span>
											</span>
											<el-button type="primary" size="mini" @click="bianjiyongjinchange(item)">编辑</el-button>
										</div>
									</div>
									<div>
										<el-button type="primary" size="mini" @click="bianjiyongjinlogshow">新增佣金规则</el-button>
									</div>
								</el-form-item>
								<el-form-item label="佣金规则设置:">
									<el-button type="primary" size="mini" @click="zhidingguize">为分销商指定规则</el-button>
								</el-form-item>
								<el-form-item label="提卡费:">
									<el-input v-model="tika_cost" @input='dayu0' class="w200" type="number" style="width: 200px;" placeholder="提卡费"></el-input>
									<span style="color: #999; margin-left: 20px;">根据设置金额向分销商收取提卡费</span>
								</el-form-item>
								<el-form-item label="上架通知:" class="shangjia" >

									<el-checkbox v-model="moneyform.is_notice">给可见商品的分销商发送新商品上架通知</el-checkbox>

								</el-form-item>
							</el-form>
						</div>
					</div>
					<div class="step" v-if="showmoney" style="text-align: center;">
						<el-button type="danger" @click="bangding()">发布商品</el-button>
					</div>

				</div>
			</div>
		</div>
		<el-dialog title="自定义抓单ID" :visible.sync="randomlog" width="400px">
			<div class="randomdiv">
				<el-input v-model="randomvalue" @input="randomnumwrite" placeholder="自定义抓单ID"></el-input>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="randomlog = false">取 消</el-button>
				<el-button type="primary" @click="randomgo" :disabled="randomone">确 定</el-button>
			</span>
		</el-dialog>
		<el-dialog title="自定义产品类型" :visible.sync="taglog" width="400px">
			<div class="protag">
				<el-tag :key="item.id" v-for="item in typelist" closable :disable-transitions="false" @close="handleClose(item.name)">{{item.name}}</el-tag>
				<el-input class="input-new-tag" v-if="inputVisible" v-model="inputValue" ref="saveTagInput" size="small"
				 @keyup.enter.native="handleInputConfirm" @blur="handleInputConfirm">
				</el-input>
				<el-button v-else class="button-new-tag" size="small" @click="showInput">输入自定义名称</el-button>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="dialogVisible = false">取 消</el-button>
				<el-button type="primary" @click="dialogVisible = false">确 定</el-button>
			</span>
		</el-dialog>
		<el-dialog title="编辑分销商佣金" :visible.sync="zidingyilog" :close-on-press-escape="false" :close-on-click-modal="false" width="800px">

		  <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
		      <el-tab-pane label="按分销商指定" name="first">
		        <div class="zidingyiflex">
		            <el-input placeholder="分销商店铺名" v-model="search" style="width: 250px; margin-right: 10px;"></el-input>
		            <el-button type="primary" @click="searchgo" style="padding: 10px 20px;" icon="el-icon-search"></el-button>
		        </div>
		        <div class="zidingyiflex" style="background: #EAEAEA; margin-top: 20px;">
		            <div class="zidingyitd">分销商店铺</div>
		            <div class="zidingyitd" style="flex: 3;">当前佣金</div>
		            <div class="zidingyitd">编辑</div>
		        </div>
		        <div class="zidingyiflex"  v-for="item in shoplist" :key="item.child_shop_id">

		            <div class="zidingyitd">{{item.merchant_name}}</div>
		            <div class="zidingyitd" v-if="item.config_id == 0" style="flex: 3;">
		                <span>默认规则：</span>
		                <span v-if="morenyongjin.rules != ''">{{morenyongjin.rules}}</span>
		                <span v-if="morenyongjin.active_commission > 0">已激活，佣金{{morenyongjin.active_commission}}元.</span>
		                <span v-if="morenyongjin.first_recharge_one > 0">首充大于{{morenyongjin.first_recharge_one}}元，佣金{{morenyongjin.first_recharge_one_commission}}元或者</span>
		                <span v-if="morenyongjin.first_recharge_two > 0">首充大于{{morenyongjin.first_recharge_two}}元，佣金{{morenyongjin.first_recharge_two_commission}}元.</span>
		                <span v-if="morenyongjin.recharge_amount_one > 0">累计充值大于{{morenyongjin.recharge_amount_one}}元，佣金{{morenyongjin.recharge_amount_one_commission}}元且</span>
		                <span v-if="morenyongjin.recharge_amount_two > 0">累计充值大于{{morenyongjin.recharge_amount_two}}元，佣金{{morenyongjin.recharge_amount_two_commission}}元.</span>
		            </div>
		            <div class="zidingyitd" v-if="item.config_id != 0" style="flex: 3;">
		              <span>{{item.name}}：</span>
		              <span v-if="item.rules != ''">{{item.rules}}</span>
		              <span v-if="item.active_commission > 0">已激活，佣金{{item.active_commission}}元.</span>
		              <span v-if="item.first_recharge_one > 0">首充大于{{item.first_recharge_one}}元，佣金{{item.first_recharge_one_commission}}元或者</span>
		              <span v-if="item.first_recharge_two > 0">首充大于{{item.first_recharge_two}}元，佣金{{item.first_recharge_two_commission}}元.</span>
		              <span v-if="item.recharge_amount_one > 0">累计充值大于{{item.recharge_amount_one}}元，佣金{{item.recharge_amount_one_commission}}元且</span>
		              <span v-if="item.recharge_amount_two > 0">累计充值大于{{item.recharge_amount_two}}元，佣金{{item.recharge_amount_two_commission}}元.</span>
		            </div>
		            <div class="zidingyitd" ><el-button @click="zidingyibianji(item.config_id,item.child_shop_id)">编辑</el-button></div>

		        </div>
		      </el-tab-pane>
		      <el-tab-pane label="按佣金规则指定" name="second">

		          <el-table :data="bianjiyongjinlist" border style="width: 100%">
		              <el-table-column prop="name" label="规则名称" width="180"></el-table-column>
		              <el-table-column>
		                <template slot-scope="scope">
		                       <span v-if="scope.row.rules != ''">{{scope.row.rules}}</span>
		                       <span v-if="scope.row.active_commission > 0">已激活，佣金{{scope.row.active_commission}}元。</span>
		                       <span v-if="scope.row.first_recharge_one > 0">首充大于{{scope.row.first_recharge_one}}元，佣金{{scope.row.first_recharge_one_commission}}元。</span>
		                       <span v-if="scope.row.first_recharge_two > 0">首充大于{{scope.row.first_recharge_two}}元，佣金{{scope.row.first_recharge_two_commission}}元。</span>
		                       <span v-if="scope.row.recharge_amount_one > 0">累计充值大于{{scope.row.recharge_amount_one}}元，佣金{{scope.row.recharge_amount_one_commission}}元。</span>
		                       <span v-if="scope.row.recharge_amount_two > 0">累计充值大于{{scope.row.recharge_amount_two}}元，佣金{{scope.row.recharge_amount_two_commission}}元。</span>
		                </template>
		              </el-table-column>
		              <el-table-column>
		                <template slot-scope="scope">
		                    <el-button type="primary" size="mini" @click="guanli(scope.row)">管理</el-button>
		                </template>
		              </el-table-column>
		          </el-table>
		      </el-tab-pane>
		  </el-tabs>



		</el-dialog>
		<el-dialog :title="tit" :visible.sync="bianjiyongjinlog" :before-close="bianliyongjinlogclose" :close-on-click-modal="false" :close-on-press-escape="false" width="920px">
		      <div style="margin-bottom: 20px; display: flex; ">
		          <div style="width: 120px; line-height: 36px;">规则名称：</div>
		          <div v-if="bianjiyongjinlist.length == 0 "><el-input v-model="first_rules.name" disabled placeholder="请输入规则名称"></el-input></div>
		          <div v-if="bianjiyongjinlist.length != 0 "><el-input v-model="first_rules.name" placeholder="请输入规则名称"></el-input></div>
		      </div>
		      <div style="margin-bottom: 20px; display: flex; ">
		        <div style="width: 120px; line-height: 36px;">佣金描述：</div>
		        <div><el-input v-model="first_rules.rules" placeholder="请输入佣金描述"></el-input></div>
		      </div>
		      <div style="margin-bottom: 20px; display: flex;">
		          <div style="width: 120px; line-height: 36px;">规则定义：</div>
		          <div class="newcon">
		                <div class="newflex">
		                    <div class="newflexli1" style="padding: 15px 0;">满足条件</div>
		                    <div class="newflexli2" style="padding: 15px 0;">支出佣金</div>
		                </div>
		                <div class="newflex">
		                    <div class="newflexli1 newflex2">
		                        <div class="newflexli11"><el-checkbox v-model="active"  @change="change_active">已激活</el-checkbox></div>
		                        <div class="newflexli12">  </div>
		                    </div>
		                    <div class="newflexli2"><el-input  type="number" :disabled="!active"  v-model="first_rules.active_commission" @input="inputchoose"  placeholder="请输入金额"></el-input></div>
		                </div>
		                <div class="newflex">
		                    <div class="newflexli1 newflex2">
		                        <div class="newflexli11"><el-checkbox v-model="first_recharge" @change="change_first_recharge">已首充</el-checkbox></div>
		                        <div class="newflexli12">
		                            <div>充值≥：<el-input :disabled="!first_recharge" v-model="first_rules.first_recharge_one" @input="inputchoose" placeholder="请输入金额"></el-input></div>
		                            <div>充值≥：<el-input :disabled="!first_recharge" v-model="first_rules.first_recharge_two" @input="inputchoose" placeholder="请输入金额"></el-input></div>
		                        </div>
		                    </div>
		                    <div class="newflexli2">
		                        <div><el-input :disabled="!first_recharge" v-model="first_rules.first_recharge_one_commission" @input="inputchoose" placeholder="请输入金额"></el-input></div>
		                        <div><el-input :disabled="!first_recharge" v-model="first_rules.first_recharge_two_commission" @input="inputchoose" placeholder="请输入金额"></el-input></div>
		                    </div>
		                </div>
		                <div class="newflex">
		                    <div class="newflexli1 newflex2">
		                        <div class="newflexli11"><el-checkbox v-model="recharge_amount"  @change="change_recharge_amount">累计充值金额</el-checkbox></div>
		                        <div class="newflexli12">
		                            <div>充值≥：<el-input :disabled="!recharge_amount" v-model="first_rules.recharge_amount_one" @input="inputchoose" placeholder="请输入金额"></el-input></div>
		                            <div>充值≥：<el-input :disabled="!recharge_amount" v-model="first_rules.recharge_amount_two" @input="inputchoose" placeholder="请输入金额"></el-input></div>
		                        </div>
		                    </div>
		                    <div class="newflexli2">
		                        <div><el-input :disabled="!recharge_amount" v-model="first_rules.recharge_amount_one_commission" @input="inputchoose" placeholder="请输入金额"></el-input></div>
		                        <div><el-input :disabled="!recharge_amount" v-model="first_rules.recharge_amount_two_commission" @input="inputchoose" placeholder="请输入金额"></el-input></div>
		                    </div>
		                </div>

		          </div>
		        </div>
		          <div class="newalt" style="margin-top: 20px;">
		            当前设定规则：
		            <span v-if="first_rules.rules != ''">{{first_rules.rules}}</span>
		            <span v-if="active == true">已激活，佣金{{first_rules.active_commission}}元.</span>
		            <span v-if="first_recharge == true">首充大于{{first_rules.first_recharge_one}}元，佣金{{first_rules.first_recharge_one_commission}}元</span>
		            <span v-if="first_recharge == true">或者首充大于{{first_rules.first_recharge_two}}元，佣金{{first_rules.first_recharge_two_commission}}元.</span>
		            <span v-if="recharge_amount == true">累计充值大于{{first_rules.recharge_amount_one}}元，佣金{{first_rules.recharge_amount_one_commission}}元</span>
		            <span v-if="recharge_amount == true">且累计充值大于{{first_rules.recharge_amount_two}}元，佣金{{first_rules.recharge_amount_two_commission}}元.</span>
		          </div>

		          <div class="newalt" style="margin-top: 20px;" v-if="first_rules.start_at">
		            定时生效： <span>{{first_rules2.start_at}}</span>
		            <span v-if="first_rules2.rules != ''">{{first_rules2.rules}}</span>
		            <span v-if="first_rules2.active_commission != 0 ">已激活，佣金{{first_rules2.active_commission}}元.</span>
		            <span v-if="first_rules2.first_recharge_one != 0 || first_rules2.first_recharge_one_commission != 0 ">首充大于{{first_rules2.first_recharge_one}}元，佣金{{first_rules2.first_recharge_one_commission}}元</span>
		            <span v-if="first_rules2.first_recharge_two != 0  || first_rules2.first_recharge_two_commission != 0 ">或者首充大于{{first_rules2.first_recharge_two}}元，佣金{{first_rules2.first_recharge_two_commission}}元.</span>
		            <span v-if="first_rules2.recharge_amount_one != 0  || first_rules2.recharge_amount_one_commission != 0 ">累计充值大于{{first_rules2.recharge_amount_one}}元，佣金{{first_rules2.recharge_amount_one_commission}}元</span>
		            <span v-if="first_rules2.recharge_amount_two != 0  || first_rules2.recharge_amount_two_commission != 0 ">且累计充值大于{{first_rules2.recharge_amount_two}}元，佣金{{first_rules2.recharge_amount_two_commission}}元.</span>
		          </div>

		      <span slot="footer" class="dialog-footer">
		      	<el-button @click="bianjiyongjinlog = false">取 消</el-button>
		        <el-button type="primary" @click="savefanli2" v-if="tit == '修改佣金规则'">定时生效</el-button>
		      	<el-button type="primary" @click="savefanli" v-if="!first_rules.start_at">立即生效</el-button>
		      </span>
		</el-dialog>
		<!-- <el-dialog title="编辑分销商佣金" :visible.sync="zidingyilog" :close-on-press-escape="false" :close-on-click-modal="false"
		 width="800px">
			<div class="zidingyiflex">
				<el-input placeholder="分销商店铺名" v-model="search" style="width: 250px; margin-right: 10px;"></el-input>
				<el-button type="primary" @click="searchgo" style="padding: 10px 20px;" icon="el-icon-search"></el-button>
			</div>
			<div class="zidingyiflex" style="background: #EAEAEA; margin-top: 20px;">
				<div class="zidingyitd">分销商店铺</div>
				<div class="zidingyitd" style="flex:3;">当前佣金</div>
				<div class="zidingyitd">编辑</div>
			</div>
			<div class="zidingyiflex" v-for="item in shoplist" :key="item.child_shop_id">
				<div class="zidingyitd">{{item.merchant_name}}</div>
				<div class="zidingyitd" v-if="item.config_id == 0 || item.config_id == null" style="flex:3;">
					<span>默认规则：</span>
					<span v-if="morenyongjin.rules != ''">{{morenyongjin.rules}}</span>
					<span v-if="morenyongjin.active_commission > 0">已激活，佣金{{morenyongjin.active_commission}}元.</span>
					<span v-if="morenyongjin.first_recharge_one > 0">首充大于{{morenyongjin.first_recharge_one}}元，佣金{{morenyongjin.first_recharge_one_commission}}元</span>
					<span v-if="morenyongjin.first_recharge_two > 0">或者首充大于{{morenyongjin.first_recharge_two}}元，佣金{{morenyongjin.first_recharge_two_commission}}元.</span>
					<span v-if="morenyongjin.recharge_amount_one > 0">累计充值大于{{morenyongjin.recharge_amount_one}}元，佣金{{morenyongjin.recharge_amount_one_commission}}元</span>
					<span v-if="morenyongjin.recharge_amount_two > 0">且累计充值大于{{morenyongjin.recharge_amount_two}}元，佣金{{morenyongjin.recharge_amount_two_commission}}元.</span>
				</div>
				<div class="zidingyitd" v-if="item.config_id != 0 && item.config_id != null" style="flex:3;">
					<span>{{item.name}}：</span>
					<span v-if="item.rules != ''">{{item.rules}}</span>
					<span v-if="item.active_commission > 0">已激活，发放佣金{{item.active_commission}}元.</span>
					<span v-if="item.first_recharge_one > 0">首充大于{{item.first_recharge_one}}元，发放佣金{{item.first_recharge_one_commission}}元或者</span>
					<span v-if="item.first_recharge_two > 0">首充大于{{item.first_recharge_two}}元，发放佣金{{item.first_recharge_two_commission}}元.</span>
					<span v-if="item.recharge_amount_one > 0">累计充值大于{{item.recharge_amount_one}}元，发放佣金{{item.recharge_amount_one_commission}}元且</span>
					<span v-if="item.recharge_amount_two > 0">累计充值大于{{item.recharge_amount_two}}元，发放佣金{{item.recharge_amount_two_commission}}元.</span>
				</div>
				<div class="zidingyitd">
					<el-button @click="zidingyibianji(item.config_id,item.child_shop_id)">编辑</el-button>
				</div>

			</div>
		</el-dialog> -->
		<el-dialog title="自定义编辑" :visible.sync="zidingyixuanzelog" :close-on-press-escape="false" :close-on-click-modal="false"
		 width="800px">
			<div v-for="item in bianjiyongjinlist" :key="item.id">
				<el-radio v-model="zidingyiradio" :label="item.id" style="margin: 20px;">{{item.name}}</el-radio>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="zidingyixuanzelog = false">取 消</el-button>
				<el-button type="primary" @click="zidingyiradiook">确 定</el-button>
			</span>
		</el-dialog>
    <el-dialog title="定时生效时间设置" :visible.sync="dingshilog" :close-on-press-escape="false" :close-on-click-modal="false" width="600px">
        <el-date-picker v-model="dingshi" type="datetime" value-format="yyyy-MM-dd HH:mm" placeholder="选择日期时间"></el-date-picker>
        <span slot="footer" class="dialog-footer">
        	<el-button @click="dingshilog = false">取 消</el-button>
        	<el-button type="primary" @click="savefanli2ok">确 定</el-button>
        </span>
    </el-dialog>

    <el-dialog title="根据佣金规则管理代理商" :visible.sync="guizelistlog" :close-on-press-escape="false" :close-on-click-modal="false" width="800px">
        <el-button type="primary" size="mini" @click="tianjiadailishang()">添加代理商</el-button>
        <el-table :data="genjuguize" border style="width: 100%; margin-top: 20px;">
            <el-table-column prop="merchant_name" label="代理商" ></el-table-column>
            <el-table-column label="操作">
              <template slot-scope="scope">
                  <el-button type="primary" size="mini" @click="guanlishan(scope.row)" v-if="scope.row.type == 3">删除</el-button>
              </template>
            </el-table-column>
        </el-table>
    </el-dialog>

    <el-dialog title="根据佣金规则管理代理商" :visible.sync="tianjiadailishanglog" :close-on-press-escape="false" :close-on-click-modal="false" width="800px">
        <el-select v-model="xin.child_shop_id" filterable placeholder="请选择">
            <el-option v-for="item in shoplist" :key="item.child_shop_id" :label="item.merchant_name"  :value="item.child_shop_id"> </el-option>
        </el-select>
        <span slot="footer" class="dialog-footer">
        	<el-button @click="tianjiadailishanglog = false">取 消</el-button>
        	<el-button type="primary" @click="tianjiadailishanggo">确 定</el-button>
        </span>
    </el-dialog>
		<!-- <foot></foot> -->
	</div>
</template>

<script>
	import {
		provinceAndCityDataPlus,provinceAndCityData,
		CodeToText,
		TextToCode
	} from 'element-china-area-data'
	import UploadExcelComponent from "@/components/UploadExcel/index.vue";
	import E from 'wangeditor'
	import axios from 'axios'
	import top from '@/components/top.vue'
	import left from '@/components/left.vue'
	import foot from '@/components/foot.vue'
  import dizhi from '@/views/yonghuyunying/zujian/dizhi.vue'
  import chuantu from "../zujian/chuantu.vue";
  import zdzd from "./zdzd.vue";
	export default {
		components: {
			"left": left,
			"top": top,
			"foot": foot,
			UploadExcelComponent,
      dizhi,chuantu,zdzd
		},
		name: 'addPros',
		data() {
			return {
        chuantushow:false,
				child_shop_id: "",
				zidingyixuanzelog: false,
				shoplist: "",
				zidingyiradio: "1",
				zidingyilog: false,
				bianjiyongjinlog: false,
				bianjiyongjinlist: "",
				morenyongjin: "",
				taglog: false,
				taglist: ['类型1', '类型2'],
				inputVisible: false,
				inputValue: '',

				active: false,
				first_recharge: false,
				recharge_amount: false,
				first_rules: {
					rules: "",
					active_commission: 0,
					first_recharge_one: 0,
					first_recharge_one_commission: 0,
					first_recharge_two: 0,
					first_recharge_two_commission: 0,
					recharge_amount_one: 0,
					recharge_amount_one_commission: 0,
					recharge_amount_two: 0,
					recharge_amount_two_commission: 0
				},
				rebate_rule: "",

				mingan: {
					city: "",
					citys: [],
					fixcitys: []
				},
				randomnum: "",
				jingdongrandom: "",
				search: "",
				msg: "hello",
				log: false,
				loading: false,

				typelist: {},
				citylist: provinceAndCityData,
				rules: {
					operator: [{
						required: true,
						message: '必选',
						trigger: 'change'
					}],
					name: [{
						required: true,
						message: '必填',
						trigger: 'blur'
					}],
					sku: [{
						required: true,
						message: '必填',
						trigger: 'blur'
					}],
					city: [{
						required: true,
						message: '请选择活动区域',
						trigger: 'change'
					}],
					real_name_type: [{
						required: true,
						message: '请输入',
						trigger: 'change'
					}],
					randomnum: [{
						required: true,
						message: '请输入抓单码',
						trigger: 'change'
					}],
					// title: [{ required: true, message: '必填', trigger: 'change' }],
					is_need_photo: [{
						required: true,
						message: '必选',
						trigger: 'change'
					}],
					img: [{
						required: true,
						message: '必选',
						trigger: 'change'
					}],
					edit: [{
						required: true,
						message: '必填',
						trigger: 'change'
					}],
					visible: [{
						required: true,
						message: '必选',
						trigger: 'change'
					}],
					commission: [{
						required: true,
						message: '必填',
						trigger: 'change'
					}],
				},
				form: {
					produce_address: "",
					operator: "",
					name: "",
					sku: "",
					plan_type_id: "",
					province: "",
					city: [],
					real_name_type: '0',
					produce_remark: "",
					status: "",
					comname: "",
					min_age: 18,
					max_purchase: 5,

					haochinum: 1,
					haochival: 1,

					address_province: "",
					address_city: "",
					address_district: "",
					commission_rule: "",
          commission_notes:"",
				},
				shopform: {
					product_id: "",
					title: "",
					status: 0,
					parent_id: "",
					selling_point: "",
					commission_rule: "",
          commission_notes: "",
					is_need_photo: '0',
					description: "",
					image1: "",
					imageUrl: '',
					imageUrl2: '',
					expect_income:"",
					share_img:"",
					auto_transfer:'',
					auto_transfer_sources:[],
					auto_transfer_pages:[],

          discount_rent:"",
          recharge_present:"",
          active_present:"",
          recharge_type:"",
          active_type:"",
          agreed_period:"",

          goods_name:"",
          operator:""
				},
				moneyform: {
					order_page_id: "",
					visible: '1',
					commission: "",
					child_shop_ids: "",
					dislist: "",
					money: "",
					list: "",
					is_notice:true
				},
				rules: {
					operator: [{
						required: true,
						message: '请选择活动区域',
						trigger: 'change'
					}],
					name: [{
						required: true,
						message: '必填',
						trigger: 'blur'
					}],
					sku: [{
						required: true,
						message: '必填',
						trigger: 'blur'
					}],
					city: [{
						required: true,
						message: '请选择活动区域',
						trigger: 'change'
					}],
					real_name_type: [{
						required: true,
						message: '请输入',
						trigger: 'change'
					}],
					randomnum: [{
						required: true,
						message: '请输入抓单码',
						trigger: 'change'
					}],
					// title: [{ required: true, message: '必填', trigger: 'change' }],
					is_need_photo: [{
						required: true,
						message: '必选',
						trigger: 'change'
					}],
					img: [{
						required: true,
						message: '必选',
						trigger: 'change'
					}],
					edit: [{
						required: true,
						message: '必填',
						trigger: 'change'
					}],
					visible: [{
						required: true,
						message: '必选',
						trigger: 'change'
					}],
					commission: [{
						required: true,
						message: '必选',
						trigger: 'change'
					}],
				},
				kejian: false,
				sub1: true,
				sub2: true,
				sub3: true,
				sub4: true,
				showmoney: false,
				sanlist: [
     //      {
					// 	name: "中国联通",
					// 	id: 10000
					// },
					// {
					// 	name: "中国移动",
					// 	id: 10086
					// },
					// {
					// 	name: "中国电信",
					// 	id: 10010
					// },
					{name:"中国广电",id:10099}
				],
				stat: "",
				randomvalue: "",
				randomone: false,
				randomlog: false,
				shop_id: "",
				tika_cost: "",
				split_list:[],
				cishu:0,

        shop_id:"",
        tit:"增加佣金规则",
        dingshilog:false,
        dingshi:"",
        dingshidata:"",

        genjuguize:[],
        guizelistlog:false,
        tianjiadailishanglog:false,
        xin:{
          order_page_id: "",
          child_shop_id: "",
          config_id: ""
        },
         activeName:"first",
         guishudi_all:"",
         cd_type_radio:4,
         cd_number:"0",

         provinceData: provinceAndCityData,
         cityData: [],
         provinceText: '',
         cityText: '',
		 isxn:false,

     fanli_money_array:[]
			}
		},
		created() {
			//获取分销商
			this.getdislist()
			// this.getmoneylist2()
			//获取返利规则
			// this.getfanli()
			//获取类型
			this.getproductstype();
			this.getshopdetail();
			axios.get('/api/gth/user/shop')
				.then(response => {
					if (response.data.msg.code == 0) {
						this.shop_id = response.data.data.shop_id
					} else {
						if (response.data.msg.code == 50401) {
							that.$router.push({
								path: "/login"
							});
							return false
						}
						that.$message.error(response.data.msg.info);
					}
				})
		},
		mounted() {

      this.citylist.forEach(item=>{
        if(item.label == '北京市'){
          item.children.forEach(item=>{
            item.label = '北京市'
          })
        }
        if(item.label == '上海市'){
          item.children.forEach(item=>{
            item.label = '上海市'
          })
        }
        if(item.label == '重庆市'){
          item.children.forEach(item=>{
            item.label = '重庆市'
          })
        }
        if(item.label == '天津市'){
          item.children.forEach(item=>{
            item.label = '天津市'
          })
        }
      })

			var that = this
			var editor = new E('#editor');
			editor.customConfig.uploadImgServer = '/upload'
			editor.customConfig.showLinkImg = false
			editor.customConfig.onchange = function(html) {
				that.shopform.description = html
			}
			editor.customConfig.customUploadImg = function(files, insert) {
				var formData = new FormData();
				formData.append("pic", files[0]);
				axios.post('/api/plan-market/order-page/upload-pic', formData)
					.then(response => {
						if (response.data.msg.code == 0) {
							insert(response.data.data)

						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			}
			editor.create();

			//套餐详细信息
			var editorE2 = new E('#editorE2');
			editorE2.customConfig.uploadImgServer = '/upload'
			editorE2.customConfig.showLinkImg = false
			editorE2.customConfig.onchange = function(html) {
				that.shopform.package_text = html
			}
			editorE2.customConfig.customUploadImg = function(files, insert) {

				var formData = new FormData();
				formData.append("pic", files[0]);
				axios.post('/api/plan-market/order-page/upload-pic', formData)
					.then(response => {
						if (response.data.msg.code == 0) {
							insert(response.data.data)
						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			}
      editorE2.create();

			var that = this;

			axios.get('/api/plan-market/order-page?order_page_id=' + this.$route.query.id)
				.then(response => {
					if (response.data.msg.code == 0) {
						var arr = ""
						for (var i in response.data.data.selling_point) {
							arr = arr + response.data.data.selling_point[i] + '，'
						}
						response.data.data.selling_point = arr.substr(0, arr.length - 1);

						that.shopform = response.data.data
						this.shopform.auto_transfer =0
						this.shopform.auto_transfer_pages =[]
						this.shopform.auto_transfer_sources =[]
						that.randomnum = response.data.data.fetch_code
						that.jingdongrandom = response.data.data.fetch_code2
						editor.txt.html(this.shopform.description)
            editorE2.txt.html(this.shopform.package_text)

            that.shopform.commission_notes = ''

            this.chuantushow = true
						//随机生成10位数
						axios.get('/api/sys/str-random')
							.then(response => {
								if (response.data.msg.code == 0) {
									this.randomnum = response.data.data
								} else {
									this.$message.error(response.data.msg.info);
								}

							})
					} else {
						that.$message.error(response.data.msg.info);
					}
				})
		},
		methods: {
      //添加月份
      changefanli_money_array:function(){
        this.fanli_money_array.push(0)
      },
      getimg:function(img){
        this.shopform.image1 = img
      },
      getimg2:function(img){
        this.shopform.share_img = img
      },
      xuanzhongde:function(item){
        this.shopform.guishudi = item.zi
        this.shopform.guishudi_code = item.shu
        // this.all.province = item
      },
      // handleChangeProvince(value) {
      //       this.cityData = []
      //       this.cityText = ''
      //       const province = CodeToText[value]
      //       if (province === '北京市' || province === '天津市' || province === '上海市' || province === '重庆市' ||
      //         province === '香港特别行政区' || province === '澳门特别行政区') {
      //         const city = { value: value, label: province }
      //         this.cityData.push(city)
      //       } else {
      //         const childList = this.provinceData.find(i => i.value === value).children
      //         this.cityData.push(...childList)
      //       }
      //       console.log(this.provinceText,this.cityText)

      // },
      // guishudi:function(val){
      //   if(val[0] == '全部'){
      //     this.shopform.guishudi_province = ''
      //   }else{
      //     this.shopform.guishudi_province = CodeToText[val[0]]
      //   }
      //   if(val[1] == '全部'){
      //     this.shopform.guishudi_city = ''
      //   }else{
      //     this.shopform.guishudi_city = CodeToText[val[1]]
      //   }
      // },
      guanlishan:function(item){
        this.$confirm('此操作将永久删除, 是否继续?', '提示', {
                  confirmButtonText: '确定',
                  cancelButtonText: '取消',
                  type: 'warning'
                }).then(() => {
                  console.log(item)
                  //管理删除
                  axios.post('/api/plan-market/order-page/commissions/update',{
                    order_page_id: this.moneyform.order_page_id,
                    child_shop_id: item.child_shop_id,
                    config_id: 0
                  })
                  	.then(response => {
                  		if(response.data.msg.code == 0){
                        this.$message({
                          message: '删除成功！',
                          type: 'success'
                        });
                        this.getmoneylist()
                        //添加后重新获取一下列表
                        axios.get('/api/plan-market/order-page/commissions?_page_size=2000&order_page_id='+this.moneyform.order_page_id+'&config_id='+this.xin.config_id)
                        	.then(response => {
                        		if(response.data.msg.code == 0){
                              this.genjuguize = response.data.data.data

                        		}else{
                        			this.$message.error(response.data.msg.info);
                        		}
                        	})

                        this.tianjiadailishanglog = false
                  		}else{
                  			this.$message.error(response.data.msg.info);
                  		}
                  	})
                })

      },
      tianjiadailishang:function(){
        this.tianjiadailishanglog = true
      },
      tianjiadailishanggo:function(){
        axios.post('/api/plan-market/order-page/commissions/update',this.xin)
        	.then(response => {
        		if(response.data.msg.code == 0){
              this.$message({
                message: '保存成功！',
                type: 'success'
              });
              this.getmoneylist()
              //添加后重新获取一下列表
              axios.get('/api/plan-market/order-page/commissions?_page_size=2000&order_page_id='+this.moneyform.order_page_id+'&config_id='+this.xin.config_id)
              	.then(response => {
              		if(response.data.msg.code == 0){
                    this.genjuguize = response.data.data.data

              		}else{
              			this.$message.error(response.data.msg.info);
              		}
              	})

              this.tianjiadailishanglog = false
        		}else{
        			this.$message.error(response.data.msg.info);
        		}
        	})
      },
      guanli:function(item){
        console.log(item)
        this.xin.order_page_id = this.moneyform.order_page_id
        if(item.type == 1){
          this.xin.config_id = 0
        }else{
          this.xin.config_id = item.id
        }
        this.xin.child_shop_id = ""

        //获取列表genjuguize
        // /api/plan-market/order-page/commissions?_page_size=2000&order_page_id=613626&name=
        axios.get('/api/plan-market/order-page/commissions?_page_size=2000&order_page_id='+this.moneyform.order_page_id+'&config_id='+this.xin.config_id)
        	.then(response => {
        		if(response.data.msg.code == 0){
              this.genjuguize = response.data.data.data
              this.guizelistlog = true
        		}else{
        			this.$message.error(response.data.msg.info);
        		}
        	})

      },



      change_active:function(){
        if(!this.active){
          this.first_rules.active_commission = 0
        }
      },
      change_first_recharge:function(){
        if(!this.first_recharge){
          this.first_rules.first_recharge_one = 0
          this.first_rules.first_recharge_two = 0
          this.first_rules.first_recharge_one_commission = 0
          this.first_rules.first_recharge_two_commission = 0
        }
      },
      change_recharge_amount:function(){
        if(!this.recharge_amount){
          this.first_rules.recharge_amount_one = 0
          this.first_rules.recharge_amount_two = 0
          this.first_rules.recharge_amount_one_commission = 0
          this.first_rules.recharge_amount_two_commission = 0
        }
      },

      savefanli2ok:function(){
        console.log(this.first_rules)
          this.$set(this.first_rules,'start_at',this.dingshi)

          axios.post('/api/plan-market/commission/page/configs/cron',this.dingshidata)
          	.then(response => {
                if(response.data.msg.code == 0){
                    this.loadingcon = false
                    this.getfanli()
                    this.$message.success("保存成功！");
                    this.bianjiyongjinlog = false
                    this.dingshilog = false
                }else{
                    this.$message.error(response.data.msg.info);
                }
          	})

          // axios.post('/api/plan-market/commission/page/configs',this.dingshidata)
          // 	.then(response => {
          //       if(response.data.msg.code == 0){
          //           this.loadingcon = false
          //           this.getfanli()
          //           this.$message.success("保存成功！");
          //           this.bianjiyongjinlog = false
          //           this.dingshilog = false
          //       }else{
          //           this.$message.error(response.data.msg.info);
          //       }
          // 	})
      },
      savefanli2:function(){
        var that = this
        var datas = {}
        datas['page_id'] = this.$route.query.id
        if(this.bianjiyongjinlist.length == 0 || this.first_rules.type == 1){
            datas['type'] = 1
        }else{
            datas['type'] = 3
        }
        datas['rules'] = this.first_rules

        this.dingshidata = datas
        this.dingshilog = true
        this.dingshi = ''

      },

			jiancha:function(){

        let arr = []
        if(this.split_list.length != 0){

          this.split_list.forEach(item=>{
            arr.push(item.sku)
          })

          axios.post('/api/plan-market/shop/skus/check',{skus:arr})
          	.then(response => {
          		if (response.data.msg.code == 0) {
          			this.shopsave()
          			this.loading = false
          		} else {
          			this.loading = false
          			this.$message.error('拆分订单所属商品' + response.data.msg.info);
          		}
          	})

        }else{
          this.shopsave()
          this.loading = false
        }



				// this.loading = true
				// if(this.split_list.length != 0){
				// 	this.checksku(this.split_list[0].sku)
				// }else{
				// 	this.shopsave()
				// 	this.loading = false
				// }
			},
			checksku:function(sku){

				// axios.post('/api/plan-market/shop/sku/check',{sku:sku})
				// 	.then(response => {
				// 		if (response.data.msg.code == 0) {
				// 			this.cishu++
				// 			if(this.cishu == this.split_list.length){
				// 				this.shopsave()
				// 				this.cishu = 0
				// 				this.loading = false
				// 			}else{
				// 				this.checksku(this.split_list[this.cishu].sku)
				// 			}
				// 		} else {
				// 			this.cishu = 0
				// 			this.loading = false
				// 			this.$message.error(sku + response.data.msg.info);
				// 			return false
				// 		}
				// 	})
			},
			changenumber:function(val){
				let v = val - this.split_list.length
				if(v > 0){
					for(let i = 0; i < v; i++){
						// 当前商品id  拆单商品sku 第几个拆单  是否检测发货1检测0不 later是多少小时后拆单 1=1小时
						this.split_list.push(
							{
								page_id:"",
								sku:"",
								split_number:"",
								check_deliver:"",
								later:""
							}
						)
					}
				}else{
					this.split_list.length = val
				}
			},
			dayu0: function() {
				if (this.tika_cost < 0) {
					this.tika_cost = 0
				}
			},
			//获取分销商和佣金
			getmoneylist2: function() {
				var that = this;
				axios.get('/api/plan-market/order-page/commissions?_page_size=10000&order_page_id=' + this.$route.query.id)
					.then(response => {
						if (response.data.msg.code == 0) {
							that.moneylist = response.data.data.data
						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//保存返利规则
			savefanli: function() {
				var that = this
				var datas = {}
				datas['page_id'] = this.moneyform.order_page_id
				if (this.bianjiyongjinlist.length == 0 || this.first_rules.type == 1) {
					datas['type'] = 1
				} else {
					datas['type'] = 3
				}
				datas['rules'] = this.first_rules

				axios.post('/api/plan-market/commission/page/configs', datas)
					.then(response => {
						if (response.data.msg.code == 0) {
							that.loadingcon = false
							that.getfanli()
							that.$message.success("保存返利成功！");
							that.bianjiyongjinlog = false
						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			},
			bianjiyongjinlogshow:function(){
        this.active = false
        this.first_recharge = false
        this.recharge_amount = false
        this.first_rules = {
        					name: "",
        					active_commission: 0,
        					first_recharge_one: 0,
        					first_recharge_one_commission: 0,
        					first_recharge_two: 0,
        					first_recharge_two_commission: 0,
        					recharge_amount_one: 0,
        					recharge_amount_one_commission: 0,
        					recharge_amount_two: 0,
        					recharge_amount_two_commission: 0
        }
			  this.tit = '新增佣金规则'
			  if(this.bianjiyongjinlist.length == 0){
			      console.log(this.first_rules)
			      this.first_rules.name = '默认规则'
			  }
			  this.bianjiyongjinlog = true
			},
			//搜索功能
			searchgo: function() {
				this.loading = true
				this.getmoneylist();
			},
			zidingyiradiook: function() {
				var that = this;
				var formData = new FormData();
				formData.append("order_page_id", this.moneyform.order_page_id);
				formData.append("child_shop_id", this.child_shop_id);
				formData.append("config_id", this.zidingyiradio);

				axios.post('/api/plan-market/order-page/commissions/update', formData)
					.then(response => {
						if (response.data.msg.code == 0) {
							that.$message({
								message: '保存成功！',
								type: 'success'
							});
							that.searchgo()
							that.zidingyilog = false
							that.zidingyixuanzelog = false
						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			},
			zidingyibianji: function(id, child_shop_id) {
				this.child_shop_id = child_shop_id
				this.zidingyiradio = id
				this.zidingyixuanzelog = true
			},
			//指定规则
			zhidingguize: function() {
				this.zidingyilog = true
			},
			//关闭添加佣金规则弹框
			bianliyongjinlogclose: function() {
				this.first_rules = {
					name: "",
					active_commission: 0,
					first_recharge_one: 0,
					first_recharge_one_commission: 0,
					first_recharge_two: 0,
					first_recharge_two_commission: 0,
					recharge_amount_one: 0,
					recharge_amount_one_commission: 0,
					recharge_amount_two: 0,
					recharge_amount_two_commission: 0
				}
				this.bianjiyongjinlog = false
			},
			//输入时的选中
			inputchoose: function() {
				if (this.first_rules.active_commission != 0 && this.first_rules.active_commission != '') {
					this.active = true
				}

				if (this.first_rules.first_recharge_one != 0 && this.first_rules.first_recharge_one != '') {
					this.first_recharge = true
				}
				if (this.first_rules.first_recharge_one_commission != 0 && this.first_rules.first_recharge_one_commission != '') {
					this.first_recharge = true
				}
				if (this.first_rules.first_recharge_two != 0 && this.first_rules.first_recharge_two != '') {
					this.first_recharge = true
				}
				if (this.first_rules.first_recharge_two_commission != 0 && this.first_rules.first_recharge_two_commission != '') {
					this.first_recharge = true
				}

				if (this.first_rules.recharge_amount_one != 0 && this.first_rules.recharge_amount_one != '') {
					this.recharge_amount = true
				}
				if (this.first_rules.recharge_amount_one_commission != 0 && this.first_rules.recharge_amount_one_commission != '') {
					this.recharge_amount = true
				}
				if (this.first_rules.recharge_amount_two != 0 && this.first_rules.recharge_amount_two != '') {
					this.recharge_amount = true
				}
				if (this.first_rules.recharge_amount_two_commission != 0 && this.first_rules.recharge_amount_two_commission != '') {
					this.recharge_amount = true
				}
			},
			getfanli: function() {
				//先获取一下商品返利
				var that = this
				axios.get('/api/plan-market/commission/page/configs?page_id=' + this.moneyform.order_page_id)
					.then(response => {
						if (response.data.msg.code == 0) {
							if (response.data.data.rules != null) {
								that.bianjiyongjinlist = response.data.data.rules
								for (var i = 0; i < that.bianjiyongjinlist.length; i++) {
									if (that.bianjiyongjinlist[i].type == 1) {
										that.morenyongjin = that.bianjiyongjinlist[i]
									}

								}
								that.inputchoose()
								that.loadingcon = false

								that.first_rules = {
									name: "",
									active_commission: 0,
									first_recharge_one: 0,
									first_recharge_one_commission: 0,
									first_recharge_two: 0,
									first_recharge_two_commission: 0,
									recharge_amount_one: 0,
									recharge_amount_one_commission: 0,
									recharge_amount_two: 0,
									recharge_amount_two_commission: 0
								}
							}
						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//编辑佣金选择自动添加入内容
			bianjiyongjinchange:async function(d){

			    await axios.get('/api/plan-market/commission/page/configs/cron/get?config_id='+d.id)
			  	.then(response => {
			        if(response.data.msg.code == 0){
                this.active = false
                this.first_recharge = false
                this.recharge_amount = false
			          this.first_rules = JSON.parse(JSON.stringify(d))
			          if(this.first_rules.active_commission > 0 ){ this.active = true}
			          if(this.first_rules.first_recharge_one > 0 || this.first_rules.first_recharge_two > 0 || this.first_rules.first_recharge_one_commission > 0 || this.first_rules.first_recharge_two_commission > 0){ this.first_recharge = true}
			          if(this.first_rules.recharge_amount_one > 0 || this.first_rules.recharge_amount_two > 0 || this.first_rules.recharge_amount_one_commission > 0 || this.first_rules.recharge_amount_two_commission > 0){ this.recharge_amount = true}


			          if(response.data.data != null && response.data.data != ''){
			            this.$set(this.first_rules,'start_at',response.data.data.start_at)
			            this.first_rules2 = response.data.data
			          }

			          this.tit = '修改佣金规则'

			          this.inputchoose()
			          this.bianjiyongjinlog = true

			        }else{
			            this.$message.error(response.data.msg.info);
			        }
			  	})


			},


			//自定义抓单码唯一性
			randomnumwrite: function() {
				var that = this
				axios.get('/api/plan-market/order-page/fetch-code/isexist?fetch_code=' + this.randomvalue)
					.then(response => {
						if (response.data.msg.code == 0) {
							that.randomone = false
						} else {
							that.randomone = true
						}
					})
			},
			//自定义抓单码点击确认
			randomgo: function() {
				this.randomnum = this.randomvalue
				this.randomlog = false
			},
			//获取商品品详情
			getshopdetail: function() {

			},
			//修改佣金时执行全部佣金赋值并保存后重新获取一下列表和佣金
			fixallmoney: function() {
				var that = this;
				var formData = new FormData();
				formData.append("order_page_id", this.moneyform.order_page_id);
				formData.append("visible", this.moneyform.visible);
				formData.append("commission", this.moneyform.commission);
				formData.append("child_shop_ids", this.moneyform.child_shop_ids);

				axios.post('/api/gth/order-page/visible', formData)
					.then(response => {
						if (response.data.msg.code == 0) {
							that.getmoneylist();
						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//个性化编辑佣金
			fixmoney: function(id) {
				this.$prompt('请输入金额', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
				}).then(response => {
					var that = this;
					var formData = new FormData();
					formData.append("order_page_id", that.moneyform.order_page_id);
					formData.append("child_shop_id", id);
					formData.append("commission", response.value);

					axios.post('/api/plan-market/order-page/commissions/update', formData)
						.then(response => {
							if (response.data.msg.code == 0) {
								this.getmoneylist();
								that.$message({
									message: '保存成功！',
									type: 'success'
								});
							} else {
								that.$message.error(response.data.msg.info);
							}
						})
				})
			},
			//获取分销商和佣金
			getmoneylist: function() {
				var that = this;
				axios.get('/api/plan-market/order-page/commissions?_page_size=10000&order_page_id=' + this.moneyform.order_page_id +
						'&name=' + this.search)
					.then(response => {
						if (response.data.msg.code == 0) {

							that.shoplist = response.data.data.data
							that.loading = false
						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			},

			chakan: function() {
				console.log(this.moneyform.child_shop_ids)
			},
			//产品名验证唯一性
			nijiushiwodeweiyi1: function() {
				var that = this;
				axios.get('/api/plan-market/product/name/isexist?name=' + that.form.name)
					.then(response => {
						if (response.data.msg.code == 0) {
							this.sub1 = true
						} else {
							this.sub1 = false
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//产品编号验证唯一性
			nijiushiwodeweiyi2: function() {
				var that = this;
				axios.get('/api/plan-market/product/sku/isexist?sku=' + this.form.sku)
					.then(response => {
						if (response.data.msg.code == 0) {
							this.sub2 = true
						} else {
							this.sub2 = false
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//商品名验证唯一性
			nijiushiwodeweiyi3: function() {
				var that = this;
				axios.get('/api/plan-market/order-page/name/isexist?title=' + this.shopform.title)
					.then(response => {
						if (response.data.msg.code == 0) {
							this.sub3 = true
						} else {
							this.sub3 = false
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//京东唯一性
			nijiushiwodeweiyi4: function() {
				this.jingdongrandom = this.jingdongrandom.trim()
				if (this.jingdongrandom == "") {
					this.sub4 = true
				} else {
					var that = this;
					axios.get('/api/plan-market/order-page/fetch-code?fetch_code2=' + this.jingdongrandom)
						.then(response => {
							if (response.data.msg.code == 0) {
								this.sub4 = true
							} else {
								this.sub4 = false
								that.$message.error(response.data.msg.info);
							}
						})
				}

			},
			//身份证审核
			cardid: function() {
				this.moneyform.child_shop_ids = "";
				if (this.moneyform.visible == 3 || this.moneyform.visible == 4) {
					this.kejian = true
				}
				if (this.moneyform.visible == 1 || this.moneyform.visible == 2) {
					this.kejian = false
				}
			},
			//获取全部分销商
			getdislist: function() {
				var that = this;
				axios.get('/api/gth/partner/list?page_size=9999')
					.then(response => {
						if (response.data.msg.code == 0) {
							that.moneyform.dislist = response.data.data.data
						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			},

			//保存商品
			shopsave: function(stat) {
        if(!this.shopform.expect_income){
          this.$message.error("预估收益必填");
          return false
        }
				if (this.sub4 == false) {
					return false
				}
				if (this.jingdongrandom == "" || this.jingdongrandom == null) {

				} else {
					if (this.jingdongrandom.length != 3) {
						this.$message.error("京东抓单码必须三位或者不填写");
						return false
					}
				}

				var that = this;
				this.stat = stat
        // if(this.provinceText){
        //   this.shopform.guishudi_province = CodeToText[this.provinceText]
        // }else{
        //   this.shopform.guishudi_province = ""
        // }
        // if(this.cityText){
        //   this.shopform.guishudi_city = CodeToText[this.cityText]
        // }else{
        //   this.shopform.guishudi_city = ""
        // }
				var formData = {
					title: this.shopform.title,
					parent_id: this.$route.query.id,
					selling_point: this.shopform.selling_point,
					commission_rule: this.shopform.commission_rule,
          commission_notes: this.shopform.commission_notes,
					is_need_photo: this.shopform.is_need_photo,
					description: this.shopform.description,
					image1: this.shopform.image1,
					fetch_code: this.randomnum,
					status: 0,
					fetch_code2: this.jingdongrandom,
          expect_income: this.shopform.expect_income,
          // guishudi_province: this.shopform.guishudi_province,
          // guishudi_city: this.shopform.guishudi_city,
          guishudi: this.shopform.guishudi,
          guishudi_code: this.shopform.guishudi_code,
          yuezu: this.shopform.yuezu,
          liuliang: this.shopform.liuliang,
          yuyin: this.shopform.yuyin,
          yuezu_time: this.shopform.yuezu_time,
          yuezu_type: this.shopform.yuezu_type,
          yongjin_time: this.shopform.yongjin_time,
          yongjin_type: this.shopform.yongjin_type,
          fanli_time: this.shopform.fanli_time,
          fanli_type: this.shopform.fanli_type,
          share_img: this.shopform.share_img,
		  dx_liuliang:this.shopform.dx_liuliang,
		  package_text:this.shopform.package_text,
		  points:this.shopform.points,
		  fanli_money:this.shopform.fanli_money,
		  is_rebate:this.shopform.is_rebate,
		  auto_transfer:this.shopform.auto_transfer,
		  auto_transfer_sources:this.shopform.auto_transfer_sources,
		  auto_transfer_pages:this.shopform.auto_transfer_pages,
      fanli_money_type:this.shopform.fanli_money_type,
      fanli_money_array:this.fanli_money_array.toString(),

      discount_rent: that.shopform.discount_rent,
      goods_name: that.shopform.goods_name,
      operator: that.shopform.operator,
      recharge_present:that.shopform.recharge_present,
      active_present:that.shopform.active_present,
      recharge_type:that.shopform.recharge_type,
      active_type:that.shopform.active_type,
      agreed_period:that.shopform.agreed_period

				}
				console.log(this.stat)
				if (this.isxn == true) {
					formData['is_virtually'] = 1
				} else {
					formData['is_virtually'] = 0
				}


				axios.post('/api/plan-market/order-page/release', formData)
					.then(response => {
						if (response.data.msg.code == 0) {
							that.moneyform.order_page_id = response.data.data.id
							//获取分销商列表和佣金
							this.getmoneylist()

							//添加拆单设置
							if(this.split_list != ''){
								this.split_list.forEach((item,index)=>{
									if(this.cd_type_radio==3){
										//按条件拆单
										item.check_deliver = 2
										item.later = "0"
									}else if(this.cd_type_radio==4){
										//按时间拆单
										if(item.check_deliver == true){
											item.check_deliver = 1
										}else{
											item.check_deliver = 0
										}
									}

									item.page_id = response.data.data.id
									item.split_number = index+1
								})
								let datas = {
									data:this.split_list,
									page_id:response.data.data.id
								}
								axios.post('/api/plan-market/split/config2', datas)
									.then(response => {
										if (response.data.msg.code == 0) {

										} else {
											that.$message.error(response.data.msg.info);
											return false
										}
									})
							}


							if (this.form.stat == 0) {
								that.$message({
									message: '保存商品成功！',
									type: 'success'
								});
								this.$router.push({
									path: '/productionDelivery'
								})
							} else {
								// that.showmoney = true;
								this.$router.push({
									path: '/productionDelivery/fixproductmoney',
									query: {
										id: this.moneyform.order_page_id,
										type:3
									}
								})
							}
						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			},

			//保存提卡费
			savetikafei: async function() {
				await axios.post('/api/gth/tika/config', {
						page_id: this.moneyform.order_page_id,
						tika_cost: this.tika_cost
					})
					.then(response => {
						if (response.data.msg.code == 0) {

						} else {
							that.$message.error(response.data.msg.info);
							return false
						}
					})
			},

			//绑定佣金分销商
			bangding: async function() {
				await this.savetikafei();

				var that = this;
				var formData = new FormData();
				formData.append("order_page_id", this.moneyform.order_page_id);
				formData.append("visible", this.moneyform.visible);
				formData.append("commission", 0);
				formData.append("is_notice", this.moneyform.is_notice);
				formData.append("child_shop_ids", this.moneyform.child_shop_ids);

				axios.post('/api/gth/order-page/visible', formData)
					.then(response => {
						if (response.data.msg.code == 0) {
							axios.post('/api/gth/order-page/put-sale', {
									order_page_id: that.moneyform.order_page_id,
									status: 100
								})
								.then(response => {
									if (response.data.msg.code == 0) {
										//绑定分销商成功后上架（落基审核）
										if (this.shop_id == 50481 || this.shop_id == 304676) {
											that.$message({
												message: '商品已发起审核！',
												type: 'success'
											});
											that.$router.push({
												path: '/productionDelivery',
											})
										} else {
											that.$message({
												message: '商品发布成功！',
												type: 'success'
											});
											that.$router.push({
												path: '/productionDelivery',
											})
										}
									} else {
										that.$message.error(response.data.msg.info);
									}
								})

						} else {
							that.$message.error(response.data.msg.info);
						}
					})
			},

			dataURLtoFile(dataurl, filename) {
			  let arr = dataurl.split(","),
			    mime = arr[0].match(/:(.*?);/)[1],
			    bstr = atob(arr[1]),
			    n = bstr.length,
			    u8arr = new Uint8Array(n);
			  while (n--) {
			    u8arr[n] = bstr.charCodeAt(n);
			  }
			  return new File([u8arr], filename, {
			    type: mime
			  });
			},
			//单个图片上传
			uploadok: function(file) {
				var that = this;
			  console.log(file.raw)
			  var reader = new FileReader()
			  var img = new Image();
			  reader.onload = function(e) {
			       img.src = e.target.result;
			  };
			  var canvas = document.createElement('canvas');
			  var context = canvas.getContext('2d');
			   // base64地址图片加载完毕后
			  let p = new Promise((r,j)=>{
			     img.onload = function () {
			          // 图片原始尺寸
			          var originWidth = this.width;
			          var originHeight = this.height;
			          // 最大尺寸限制
			          var maxWidth = 1920, maxHeight = 1080;
			          // 目标尺寸
			          var targetWidth = originWidth, targetHeight = originHeight;
			          // 图片尺寸超过400x400的限制
			          if (originWidth > maxWidth || originHeight > maxHeight) {
			              if (originWidth / originHeight > maxWidth / maxHeight) {
			                  // 更宽，按照宽度限定尺寸
			                  targetWidth = maxWidth;
			                  targetHeight = Math.round(maxWidth * (originHeight / originWidth));
			              } else {
			                  targetHeight = maxHeight;
			                  targetWidth = Math.round(maxHeight * (originWidth / originHeight));
			              }
			          }
			          // canvas对图片进行缩放
			          canvas.width = targetWidth;
			          canvas.height = targetHeight;
			          // 清除画布
			          context.clearRect(0, 0, targetWidth, targetHeight);
			          // 图片压缩
			          context.drawImage(img, 0, 0, targetWidth, targetHeight);

			          let base64 = canvas.toDataURL("image/jpeg", 0.8); // 压缩后的base64图片
			          let file2 = that.dataURLtoFile(base64, Date.parse(Date()) + ".jpg");
			          r(file2)
			     };
			  })
			  reader.readAsDataURL(file.raw);
			  p.then(files=>{
			    var formData = new FormData();
			    formData.append("pic", files);
			    axios.post('/api/plan-market/order-page/upload-pic', formData)
			    	.then(response => {
			    		if (response.data.msg.code == 0) {
			    			that.shopform.image1 = response.data.data
			    		} else {
			    			that.$message.error(response.data.msg.info);
			    		}
			    	})
			  })
			},
			uploadok2: function(file) {
				var that = this;
			  console.log(file.raw)
			  var reader = new FileReader()
			  var img = new Image();
			  reader.onload = function(e) {
			       img.src = e.target.result;
			  };
			  var canvas = document.createElement('canvas');
			  var context = canvas.getContext('2d');
			   // base64地址图片加载完毕后
			  let p = new Promise((r,j)=>{
			     img.onload = function () {
			          // 图片原始尺寸
			          var originWidth = this.width;
			          var originHeight = this.height;
			          // 最大尺寸限制
			          var maxWidth = 1920, maxHeight = 10800;
			          // 目标尺寸
			          var targetWidth = originWidth, targetHeight = originHeight;
			          // 图片尺寸超过400x400的限制
			          if (originWidth > maxWidth || originHeight > maxHeight) {
			              if (originWidth / originHeight > maxWidth / maxHeight) {
			                  // 更宽，按照宽度限定尺寸
			                  targetWidth = maxWidth;
			                  targetHeight = Math.round(maxWidth * (originHeight / originWidth));
			              } else {
			                  targetHeight = maxHeight;
			                  targetWidth = Math.round(maxHeight * (originWidth / originHeight));
			              }
			          }
			          // canvas对图片进行缩放
			          canvas.width = targetWidth;
			          canvas.height = targetHeight;
			          // 清除画布
			          context.clearRect(0, 0, targetWidth, targetHeight);
			          // 图片压缩
			          context.drawImage(img, 0, 0, targetWidth, targetHeight);

			          let base64 = canvas.toDataURL("image/jpeg", 0.8); // 压缩后的base64图片
			          let file2 = that.dataURLtoFile(base64, Date.parse(Date()) + ".jpg");
			          r(file2)
			     };
			  })
			  reader.readAsDataURL(file.raw);
			  p.then(files=>{
			    var formData = new FormData();
			    formData.append("pic", files);
			    axios.post('/api/plan-market/order-page/upload-pic', formData)
			    	.then(response => {
			    		if (response.data.msg.code == 0) {
			    			that.shopform.share_img = response.data.data
			          console.log(that.shopform.share_img)
			    		} else {
			    			that.$message.error(response.data.msg.info);
			    		}
			    	})
			  })
			},
			//选择省市区
			changeaddress: function(v) {
				this.form.address_province = CodeToText[v[0]],
					this.form.address_city = CodeToText[v[1]],
					console.log("选中的省市" + this.form.address_province + this.form.address_city)
			},
			//导入敏感地区
			exportData: function(data) {
				console.log(data)
				this.mingan.citys = []
				this.mingan.fixcitys = []
				for (var i = 0; i < data.results.length; i++) {
					console.log(this.mingan.citys)
					this.mingan.citys.push(data.results[i]['敏感地区'])
					if (data.results[i]['修改敏感地区'].indexOf(",") > -1) {
						var arr = data.results[i]['修改敏感地区'].split(',')
					} else if (data.results[i]['修改敏感地区'].indexOf("，") > -1) {
						var arr = data.results[i]['修改敏感地区'].split('，')
					} else {
						return false
						that.$message.error("数据出错了，请检查格式");
					}
					var obj = {}
					obj[arr[0]] = arr[1]
					this.mingan.fixcitys.push(obj)
				}
			},
			//获取产品类型
			getproductstype: function() {
				var that = this
				axios.get("/api/gth/plan-type")
					.then(function(response) {
						if (response.data.msg.code == 0) {
							that.typelist = response.data.data
						} else {
							that.$message.error(response.data.msg.info);
						}

					})
			},

			loggo: function() {
				console.log("a")
			},

			//自定义产品类型
			handleClose(tag) {
				this.taglist.splice(this.taglist.indexOf(tag), 1);
			},

			showInput() {
				this.inputVisible = true;
				this.$nextTick(_ => {
					this.$refs.saveTagInput.$refs.input.focus();
				});
			},

			handleInputConfirm() {
				var that = this;
				var formData = new FormData();
				formData.append("name", this.inputValue);
				axios.post('/api/gth/plan-type/release', formData)
					.then(response => {
						if (response.data.msg.code == 0) {
							that.getproductstype();
							that.$message({
								message: '添加成功',
								type: 'success'
							});
						} else {
							that.$message.error(response.data.msg.info);
						}
					})
				let inputValue = this.inputValue;
				if (inputValue) {
					this.taglist.push(inputValue);
				}
				this.inputVisible = false;
				this.inputValue = '';
			},
			// ======监听
			changesw(val){
				//修改自动转单
				console.log(val)
				this.shopform.auto_transfer =val
			},
			surecreate(val){
				//设置转单目标商品：
				console.log(val)
				var arr = []
				for(var x=0;x<val.length;x++){
					arr.push(val[x].id)
				}
				this.shopform.auto_transfer_pages =arr
			},
			handleChange(val){
				//设置转单订单来源
				console.log(val)
				this.shopform.auto_transfer_sources =val

			}
		}

	}
</script>

<style lang="scss" scoped>

  .zhouqi{ color: #666; font-size: 14px;
    /deep/ .el-input .el-input__inner{ width:120px;}
  }
  /deep/ .el-input__inner {
    background: #F3F5F8 !important;
    border: 1px #F3F5F8 solid;
  }

  .bai {
    /deep/ .el-input__inner {
      background: #fff !important;
      border: 1px #fff solid !important;
    }
  }

  /deep/ .el-icon-question {
    font-size: 18px !important;
    color: #0C83FF !important;
  }

  /deep/ .el-input .el-input__inner {
    width: 300px;
  }

	.shangjia /deep/ .el-form-item__label{ font-weight: bold;  color:#FF0000;}
	// .el-message-box__wrapper {
	// 	z-index: 20000 !important;
	// }
  /deep/ .w-e-menu{ z-index: 1001 !important;}
  /deep/ .w-e-text-container{z-index: 1000 !important; }

	.index {

    /deep/ #editorE{position: relative; z-index: 9;}
		/deep/ #editor{ position: relative; z-index: 9;
			::v-deep .w-e-text-container{ z-index: 9;}
			::v-deep .w-e-toolbar .w-e-menu{ z-index: 9;}
		}


		.zidingyiflex {
			display: flex;

			.zidingyitd {
				flex: 1;
				text-align: center;
				padding: 10px 10px;
				border: 1px #ccc solid;
				margin-left: -1px;
				margin-top: -1px;
			}
		}

		.bor3 {
			border: 1px #EAEAEA solid;
			background: #EAEAEA;
			padding: 10px;
			border-radius: 3px;
			margin-bottom: 10px;
		}

		.bor4 {
			border: 1px #EAEAEA solid;
			background: #EAEAEA;
			padding: 10px;
			border-radius: 3px;
			margin-bottom: 10px;
		}

		.newcon {
			width: 800px;
			border: 1px #EAEAEA solid;

			.newflex {
				display: flex;
				justify-content: center;
				align-items: center;
				text-align: center;
				border-bottom: 1px #EAEAEA solid;

				.newflexli1 {
					flex: 2;

					.newflexli11 {
						flex: 1;
						line-height: 36px;
						display: flex;
						justify-content: center;
						align-items: center;
					}

					.newflexli12 {
						flex: 1;
						border-left: 1px #EAEAEA solid;

						.el-input {
							width: 120px;
							margin: 5px 0;
						}
					}
				}

				.newflexli2 {
					flex: 1;
					border-left: 1px #EAEAEA solid;

					.el-input {
						width: 60%;
						margin: 5px 0;
					}
				}

				.newflex2 {
					display: flex;

					justify-content: center;
					align-items: center;
				}
			}

		}

		.loglist {
			display: flex;
			justify-content: space-between;
			margin-bottom: 30px;

			.log_title {
				padding: 7px 10px;
			}
		}

		.listl {
			height: 350px;
			overflow: auto;

			.el-input__inner {
				border: none;
				text-align: center
			}
		}

		.list {

			display: flex;
			text-align: center;
			color: #727272;
			line-height: 45px;
			border: 1px #EAEAEA solid;
			margin-top: -1px;

			.th {
				flex: 1;
				background: #F9F9F9;
				font-size: 14px;
			}

			.td {
				flex: 1;
				font-size: 14px;
				border-right: 1px #EAEAEA solid;
			}
		}

		.el-pagination {
			text-align: right;
			margin: 20px 0
		}

		// .el-dialog__wrapper {
		// 	z-index: 19999 !important;
		// }

		.protag {
			/deep/ .el-tag {
				margin-right: 20px;
				margin-bottom: 20px;
			}
		}

		.addpro {


			/deep/ .el-steps {

				padding: 30px;
			}

			.step {
				margin-bottom: 20px;
				background: #FFFFFF;

				/deep/ .el-step__icon {
					width: 36px;
					height: 36px;
				}

				/deep/ .el-step__line {
					top: 17px;
				}

				/deep/ .is-process {
					color: #C0C4CC;
					border-color: #C0C4CC;
					font-weight: 400
				}

				.redbor {
					.el-input__inner {
						border: 1px #EEF7FF solid;
					}
				}

				.tilte {
					background: #F9F9F9;
					padding-left: 30px;
					line-height: 45px;
					font-size: 14px;

					span {
						background: #B1E4FF;
						color: #FFFFFF;
						float: right;
						line-height: 15px;
						cursor: pointer;
						padding: 5px 0;
						display: block;
						width: 24px;
						text-align: center;
						margin-right: 20px;
						margin-top: 8px;
						border-radius: 14px;
					}
				}


				.con {
					background: #FFFFFF;
					padding: 35px;

					.flex {
						display: flex;
					}

					.ori {
						background: #FBFBFB;
						padding: 20px 10px;

						/deep/ .el-input {
							width: 300px;
						}

						/deep/ .el-form-item {
							margin-bottom: 20px;
						}

						/deep/ .el-form-item__label {
							width: 150px !important;
						}

						.wenhao2 {
							color: #999;
							font-size: 14px;
						}

						.no {
							display: flex;
							align-items: center;

							/deep/ #drop {
								.el-button--primary {
									background: #409EFF
								}
							}

							.nonum {
								background: #409EFF;
								padding: 0px 10px;
								line-height: 35px;
								height: 35px;
								color: #FFFFFF;
								border-radius: 3px;
								display: block;
							}

							.el-button {}

							span {
								margin: 0 20px;
							}
						}

					}
				}

				.haochi {
					padding: 30px;

					/deep/ .el-select {
						margin-left: 20px;
					}
				}

				.btm0 {
					/deep/ .el-button {
						margin-left: 20px;
					}

					/deep/ .el-form-item {
						margin-bottom: 0;
					}
				}

				.label200 /deep/ .el-form-item__label {
					width: 149px !important;
				}

				// /deep/ .avatar-uploader .el-upload {
				// 	border: 1px dashed #d9d9d9;
				// 	border-radius: 6px;
				// 	cursor: pointer;
				// 	position: relative;
				// 	overflow: hidden;
				// }

				// /deep/ .avatar-uploader .el-upload:hover {
				// 	border-color: #409EFF;
				// }

				// /deep/ .avatar-uploader-icon {
				// 	font-size: 28px;
				// 	color: #8c939d;
				// 	width: 178px;
				// 	height: 178px;
				// 	line-height: 178px;
				// 	text-align: center;
				// }

				// /deep/ .avatar {
				// 	width: 178px;
				// 	height: 178px;
				// 	display: block;
				// }

				.wenhao {
					background: #B1E4FF;
					color: #FFFFFF;
					line-height: 15px;
					cursor: pointer;
					padding: 5px 11px;
					margin-left: 20px;
					text-align: center;
					border-radius: 14px;
				}
			}

		}
	}
</style>
